function playName(a) {
    var b = new Array();
    return b["tudou"] = "土豆", b["youku"] = "优酷", b["iqiyi"] = "爱奇艺", b["letv"] = "乐视",
    b["sohu"] = "搜狐", b["pptv"] = "聚力", b["qq"] = "腾讯", b["letvyun"] = "乐视云", b["bilibili"] = "哔哩哔哩", b["acfun"] = "A站", b["other"] = "其他", b["pv"] = "PV", b["bgm"] = "BGM", b["ed"] = "ED", b["cm"] = "CM", b["op"] = "OP", b["mad"] = "MAD", b["other"] = "其他A", b["otherB"] = "其他B", b["otherC"] = "其他C", b["otherD"] = "其他D", b["nodel"] = "未删减", b[a];
}

function history(obj){
    if(PlayHistoryObj){
        var url_name = "" ;
        var json = {
            'vod_id' : obj.id ,
            'vod_pid': obj.pid,
            'vod_sid': obj.sid,
            'vod_name' : obj.name,
            'url_name' : obj.urlName,
        };
        PlayHistoryObj.addPlayHistory(json,obj.url,window.location.href);
    }
}

function scrollCur(){
    var $cura = $('.sub-main a.cur');
    if($('.sub-main a').hasClass('cur')){
        var posi=$cura.position();
        $(".tab-main").animate({scrollTop:posi.top},200);
    }
}

$(document).ready(function(){
    scrollCur();
    $('.playiconlist').hover(function(){
        $('.playicon').show();
    },function(){
        $('.playicon').hide();
    })
    $('.playicon').hover(function(){
        $(this).show()
    },function(){
        $(this).hide()
    })
    var url = 'http://www.ikanfan.com/index.php?s=home-vod-playerJson-id-' + playConfig.id
    $.getJSON(url, function(data){
        if(data.status === 0){
            var data = data.data.Data, html = '', vid, name, type, list = $('.playicon span');
            for (var e = 0; e < data.length; e++) {
                vid = playConfig.pid <= data[e].playurls.length && data[e].playurls[parseInt(playConfig.pid) - 1][1];
                if(vid){
                    type = data[e].playname;
                    name = playName(type);
                    for(var i = 0; i < list.length; i++){
                        if(name === list.eq(i).text()){
                            if(list.eq(i).hasClass('current')){
                                html += '<span class="elm bf current" data-type="' + type + '" data-vid="' + vid + '"><i class="'+ type +'"></i>' + (name === '哔哩哔哩' ? 'B站' : name) + "</span>";
                            }else{
                                html += '<span class="elm bf" data-type="' + type + '" data-vid="' + vid + '"><i class="'+ type +'"></i>' +  (name === '哔哩哔哩' ? 'B站' : name) + "</span>";
                            }
                        }
                    }
                }
            }
            $('.playicon').html('');
            $(".playicon").html(html);
            $('.playiconlist i').attr('class', $('.playicon .current').attr('data-type'));
            var text = localStorage.text = $('.playicon .current').text() === '哔哩哔哩' ? 'B站' : $('.playicon .current').text()
            $('.playiconlist em, .tab-menu li.select em').text(text);
            //点击切换播放源
            $('.playicon span').click(function(){
                var type = $(this).attr('data-type'),
                    vid = $(this).attr("data-vid"),
                    text = $(this).text();
                $('.playiconlist i').attr('class', type);
                $('.playiconlist em, .tab-menu li.select em').text(text);
                $('.tab-main').hide();
                $('#' + type).find('a').eq(playConfig.pid - 1).addClass('cur');
                $('#' + type).show();
                if(!(text === localStorage.text)){
                    (type && vid) && Play(vid, type)
                    localStorage.text = $(this).text();
                }
                scrollCur();
            })
        }
    });
    // if (1 === playConfig.setting && "" != ff_urls) {
    //     var data = JSON.parse(ff_urls).Data, html = '', vid, name, type, list = $('.playicon span');
    //     for (var e = 0; e < data.length; e++) {
    //         vid = playConfig.pid <= data[e].playurls.length && data[e].playurls[parseInt(playConfig.pid) - 1][1];
    //         if(vid){
    //             type = data[e].playname;
    //             name = playName(type);
    //             for(var i = 0; i < list.length; i++){
    //                 if(name === list.eq(i).text()){
    //                     if(list.eq(i).hasClass('current')){
    //                         html += '<span class="elm bf current" data-type="' + type + '" data-vid="' + vid + '"><i class="'+ type +'"></i>' + (name === '哔哩哔哩' ? 'B站' : name) + "</span>";
    //                     }else{
    //                         html += '<span class="elm bf" data-type="' + type + '" data-vid="' + vid + '"><i class="'+ type +'"></i>' +  (name === '哔哩哔哩' ? 'B站' : name) + "</span>";
    //                     }
    //                 }
    //             }
    //         }
    //     }
    //     $('.playicon').html('');
    //     $(".playicon").html(html);
    //     $('.playiconlist i').attr('class', $('.playicon .current').attr('data-type'));
    //     var text = localStorage.text = $('.playicon .current').text() === '哔哩哔哩' ? 'B站' : $('.playicon .current').text()
    //     $('.playiconlist em').text(text);
    // }
});

var Mar = document.getElementById("Marquee");
var child_div=Mar.getElementsByTagName("div")
var picH = 30;//移动高度
var scrollstep=3;//移动步幅,越大越快
var scrolltime=20;//移动频度(毫秒)越大越慢
var stoptime=3000;//间断时间(毫秒)
var tmpH = 0;
Mar.innerHTML += Mar.innerHTML;
function start(){
	if(tmpH < picH){
		tmpH += scrollstep;
		if(tmpH > picH )tmpH = picH ;
		Mar.scrollTop = tmpH;
		setTimeout(start,scrolltime);
	}else{
		tmpH = 0;
		Mar.appendChild(child_div[0]);
		Mar.scrollTop = 0;
		setTimeout(start,stoptime);
	}
}
onload=function(){setTimeout(start,stoptime)};
